package jmine.tec.batch;

import jmine.tec.batch.domain.ExecPhase;
import jmine.tec.batch.domain.MPhase;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

/**
 * Factory de exec phases
 * 
 * @author jrenaut
 */
public final class ExecPhaseFactory implements BeanFactoryAware {

    private BeanFactory beanFactory;

    /**
     * @param mphase uma definição de fase
     * @return uma instãncia da fase descrita
     */
    public ExecPhase createPhase(MPhase mphase) {
        ExecPhase exec = (ExecPhase) this.beanFactory.getBean(mphase.getBeanName(), ExecPhase.class);
        return exec;
    }

    /**
     * {@inheritDoc}
     */
    public void setBeanFactory(BeanFactory beanFactory) {
        this.beanFactory = beanFactory;
    }

}
